<?php
if ($_GET['code'] != "impex_cron") { die(); }
$_CONFIG = array();

require_once("smarty/smarty.class.php");
require_once("phpmailer/language/phpmailer.lang-en.php");
require_once("phpmailer/class.phpmailer.php");

require_once("_framework/load.framework.php");
require_once("config/loadconfig.php");


initDatabase();
Database::loadModel("tasks");
$emaildata = Database::getModel()->getEmailDataFor(12);
for ($ii = 0; $ii < count($emaildata); $ii++) {
    $subject = $emaildata[$ii]['subject'];
    $content = $emaildata[$ii]['content'];
    $prev = "";
    for ($iii = 0; $iii < count($emaildata[$ii]['emailfields']); $iii++) {
        $to = $emaildata[$ii][$emaildata[$ii]['emailfields'][$iii]];
        if ($prev == $to) { continue; }
        $prev = $to;
        Log::info("sending email to $to");
        sendEmailWithContent($to, $subject, $content);
    }
}

?>
